﻿using Model.Entities;
using NHibernate;
using NHibernate.Cfg;

namespace Model
{
    public sealed class NHibernateHelper
    {
        private static readonly ISessionFactory SessionFactory;

        static NHibernateHelper()
        {
            var configuration = new Configuration();
            configuration.Configure();
            configuration.AddAssembly(typeof(BaseEntity).Assembly);
            SessionFactory = configuration.BuildSessionFactory();
        }

        public static ISession CurrentSession
        {
            get
            {
                return SessionFactory.OpenSession();
            }
        }
    }
}
